module.exports = (app) => {
  const { STRING, INTEGER, DATE } = app.Sequelize;
  /**
  * 工作职位
  */
  const JobPosition = app.model.define('JobPosition', {
    id: { type: INTEGER, primaryKey: true, autoIncrement: true },
    uuid: { type: STRING(36), unique: true },
    name: { type: STRING(100) },
    FKQuestionnaire: { type: INTEGER, field: 'fk_questionnaire' },
    createdAt: { type: DATE, field: 'created_at' },
    updatedAt: { type: DATE, field: 'updated_at' },
  }, {
    tableName: 'job_positions'
  });

  JobPosition.associate = () => {
    app.model.JobPosition.belongsTo(app.model.Questionnaire, {
      foreignKey: 'fk_questionnaire',
      targetKey: 'id',
    });
  };

  return JobPosition;
};
